

import * as THREE from 'three';
import {OrbitControls} from '../../../node_modules/three/examples/jsm/controls/OrbitControls.js' 
import TWEEN from '../../../node_modules/three/examples/jsm/libs/tween.module.js';
import LineAnimate from './line_animate.js';
import showPoint from  './show_Points.js';
import showText from './show_text.js';
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );

camera.position.set(0,0,10);
scene.add(camera);


const renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setPixelRatio(window.devicePixelRatio);
//renderer.setClearColor(0x000000, 0); // 设置背景透明

document.getElementById("threeConter").appendChild( renderer.domElement );

const controls = new OrbitControls(camera, document.getElementById("threeConter"));
controls.enableRotate=false; //使不旋转

let pointStart = new THREE.Vector3(-10,0,0);
let pointEnd = new THREE.Vector3(10,0,0);

let Line_AB=new LineAnimate(scene,pointStart,pointEnd,1000);
Line_AB.start();
/*创建点组*/
const positions = [];
const colors = [];
positions.push( -10, 0, 0 );
positions.push( 0, 0, 0 );
positions.push( 5, 0, 0 );
colors.push( 1, 0, 0 );
colors.push( 0, 1, 0 );
colors.push( 0, 1, 0 );

let a=new showPoint(scene,positions,colors,0.1);

//Text test
let text=new showText(scene,pointStart,"你在这里",new THREE.Color(1,1,0),0.4);


function render() {
    TWEEN.update();
    renderer.render( scene, camera );
    //   渲染下一帧的时候就会调用render函数
    requestAnimationFrame(render);
}
    
render();
